package com.cui.project.service.impl.inner;

import com.api.common.model.entity.User;
import com.api.common.service.InnerUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.api.common.common.ErrorCode;
import com.cui.project.exception.BusinessException;
import com.cui.project.mapper.UserMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author: 崔老爷
 * Date: 2024/9/28 20:53
 * @Description:
 */

@DubboService
public class InnerUserServiceImpl implements InnerUserService {


    @Resource
    private UserMapper userMapper;

    @Override
    public User getInvokeUser(String accessKey) {
        if (StringUtils.isAllBlank(accessKey)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("accessKey", accessKey);
        User user = userMapper.selectOne(queryWrapper);
        if(user==null)
        {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        return user;
    }
}
